{include file="base/header"}
        <div class="layui-card">
            <div class="layui-card-body">
                <form class="layui-form" action="">
                    <div class="layui-form-item">
                        <div class="layui-form-item layui-inline">
                            <label class="layui-form-label">昵称/姓名</label>
                            <div class="layui-input-inline">
                                <input type="text" name="reaname" placeholder="" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item layui-inline">
                            <label class="layui-form-label">手机号</label>
                            <div class="layui-input-inline">
                                <input type="text" name="mobile" placeholder="" class="layui-input">
                            </div>
                        </div>
                       
                      
                        <div class="layui-form-item layui-inline">
                            <button class="pear-btn pear-btn-md pear-btn-primary" lay-submit lay-filter="user-query">
                                <i class="layui-icon layui-icon-search"></i>
                                查询
                            </button>
                            <button type="reset" class="pear-btn pear-btn-md">
                                <i class="layui-icon layui-icon-refresh"></i>
                                重置
                            </button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
        
        <div class="layui-card">
            <div class="layui-card-body">
                <table id="tableId" lay-filter="user-table"></table>
            </div>
        </div>
  
        <script type="text/html" id="user-img">
            <img src="{{d.head_img}}" class="layui-nav-img">
        </script>
        

      
        <script type="text/html" id="user-usermsg2">
            {{#if (d.luser ) { }}
                <img src="{{d.luser.head_img}}" class="layui-nav-img">
                <span>{{d.luser.nickname}}
                </span>
                {{#if (d.luser.mobile ) { }}
                    <span>| {{d.luser.mobile}}</span>
                {{# } }}
            {{# } }}
        </script>
        <script type="text/html" id="user-status">
            	<input type="checkbox" name="status" value="{{d.id}}" lay-skin="switch" lay-text="开启|冻结" lay-filter="user-status-set" {{ d.status ? 'checked' : '' }} />
        </script>
     
        <script type="text/html" id="user-set">
        			
      
                    
        </script>
        <script>
			layui.use(['table', 'form', 'jquery','common'], function() {
				let table = layui.table;
				let form = layui.form;
				let $ = layui.jquery;
				let common = layui.common;
                let cols = [
                    [{
                        title: 'ID',
                        field: 'id',
                        align: 'center',
                        width: 50
                    },
                    // {
                    //         title: '头像',
                    //         field: 'head_img',
                    //         align: 'center',
                    //         width: 100,
                    //         templet: '#user-img'
                    //     },
                    // {
                    //         title: '昵称',
                    //         field: 'nickname',
                    //         align: 'center',
                    //         width: 100,
                    //     },
                    // {
                    //     title: '姓名',
                    //     field: 'reaname',
                    //     align: 'center',
                    //     width: 100,
                    // },
                    {
                        title: '手机号',
                        field: 'mobile',
                        align: 'center',
                         width: 120,
                    },
                    {
                            title: '会员状态',
                            field: 'rolename',
                            align: 'center',
                             templet: '#user-status'
                        },
                       
                    {
                        title: '注册时间',
                        field: 'addtime',
                        align: 'center'
                    },
                   
                    {
                        title: '操作',
                        toolbar: '#user-set',
                        align: 'left',
                        width: 300
                    }
                    ]
                ];
                table.render({
                    elem: '#tableId',
                    url: "{:url('user/userlst')}",
                    page: true,
                    cols: cols,
                    skin: 'line',
                    toolbar: '#user-toolbar',
                    defaultToolbar: [{
                        title: '刷新',
                        layEvent: 'refresh',
                        icon: 'layui-icon-refresh',
                    }, 'filter',  'exports']
                });
                form.on('switch(user-status-set)', function (obj) {
                    console.log(obj);
                    var id= this.value;
                    var status= !obj.elem.checked ? 0 :1 ;
                    var str= status ? "已开启，可正常登录" : "已冻结，不可登录";
                    postData("{:url('user/setUserStatus')}",{ id,status }).then(function(res){
                        if(res.code!=200){
                            layer.alert(res.message,{title:"提示"});
                            return;
                        }
                        layer.tips(str, obj.othis);
                    });

                });
                
                form.on('switch(user-ish-set)', function (obj) {
                    console.log(obj);
                    var id= this.value;
                    var ish= !obj.elem.checked ? 0 :1 ;
                    var str= ish ? "已设置" : "已取消设置";
                    postData("{:url('user/setUserIsh')}",{ id,ish }).then(function(res){
                        if(res.code!=200){
                            layer.alert(res.message,{title:"提示"});
                            return;
                        }
                        layer.tips(str, obj.othis);
                    });

                });
                table.on('tool(user-table)', function (obj) {
                    if (obj.event === 'showBalance') {
                 
                        window.showBalance(obj.data);
                    }else if(obj.event ==='showyUser'){
                        window.showyUser(obj.data);
                    }else if(obj.event ==='showtUser'){
                        window.showtUser(obj.data);
                    }
                
                });
                table.on('toolbar(user-table)', function (obj) {
                    if (obj.event === 'refresh') {
						window.refresh();
					}
                });
                window.refresh = function(param) {
					table.reload('tableId');
				}

  
                
         
                form.on('submit(user-query)', function (data) {
                    table.reload('tableId', {
                        page: {curr: 1 },
                        where: data.field
                    })
                    return false;
                });

			})
		</script>
        <!-- 三年前，江南李家二公子 与父发生争执，负气离家, -->
{include file="base/footer"}